package dfbz.com.service.impl;

import dfbz.com.dao.ArticleDao;
import dfbz.com.model.Article;
import dfbz.com.model.Favorite;
import dfbz.com.service.AritcleService;

import java.util.List;
import java.util.Map;

public class ArticleServiceImp implements AritcleService {

    private ArticleDao articleDao = new ArticleDao();

    @Override
    public List findArticleList(String current, String articleName) {
        List list = articleDao.findArticle(current, articleName);
        return list;
    }

    @Override
    public Long findTotalCount(String articleName) {
        Long total = articleDao.findTotalCount(articleName);
        return total;
    }

    @Override
    public Map findArticleDetail(String id) {

        Map article = articleDao.findArticleById(id);
        return article;
    }

    @Override
    public void addArticle(Article article) {
        articleDao.add(article);
    }

    @Override
    public List findCollectArticleList(String current, String articleName, String id) {
        List list = articleDao.findCollectArticleList(current, articleName, id);
        return list;
    }

    @Override
    public Long findCollectTotalCount(String articleName, String userId) {
        Long total = articleDao.findCollectTotalCount(articleName, userId);
        return total;
    }

    @Override
    public Integer ifCollect(Integer bId, Integer uId) {

        Integer i = articleDao.ifCollect(bId, uId);
        return i;
    }

    @Override
    public void collectArticle(Favorite favorite) {
        articleDao.add(favorite);
    }

    @Override
    public void cancelCollect(int aId, int uId) {
        articleDao.cancelCollect(aId, uId);
    }

    @Override
    public List findCoCollectPeople(int aId, int uId) {

        List list = articleDao.findCoCollectPeople(aId, uId);
        return list;
    }

    @Override
    public void updateBrowseCount(Integer aId) {
        articleDao.updateBrowseCount(aId);
    }
}
